
#ifndef _WRK_CONFIG_H_INCLUDED_
#define _WRK_CONFIG_H_INCLUDED_

#define MAX_RECV 1024*4

#define WRK_HAVE_FIONBIO 1

#include <sys/types.h>

#ifndef _UINTPTR_T
#define _UINTPTR_T
typedef unsigned long       uintptr_t;
#endif /* _UINTPTR_T */

typedef long intptr_t;
typedef intptr_t        wrk_int_t;
typedef uintptr_t       wrk_uint_t;
typedef intptr_t        wrk_flag_t;
typedef pid_t           wrk_pid_t;
typedef int             wrk_fd_t;

#define wrk_memset(buf, c, n)     (void) memset(buf, c, n)
#define wrk_cpymem(dst, src, n)   (((u_char *) memcpy(dst, src, n)) + (n))
#define wrk_strlen(s)       strlen((const char *) s)
#define WRK_SETPROCTITLE_PAD	'\0'
#define WRK_SETPROCTITLE_USES_ENV   1
#define WRK_FREEBSD     1



#define wrk_signal_helper(n)     SIG##n
#define wrk_signal_value(n)      wrk_signal_helper(n)
#define wrk_value_helper(n)      #n
#define wrk_value(n)             wrk_value_helper(n)
#define wrk_memzero(buf, n)       (void) memset(buf, 0, n)

#define  WRK_OK          0
#define  WRK_ERROR      -1
#define  WRK_AGAIN      -2
#define  WRK_BUSY       -3
#define  WRK_DONE       -4
#define  WRK_DECLINED   -5
#define  WRK_ABORT      -6

#define WRK_CMD_OPEN_CHANNEL   1
#define WRK_CMD_CLOSE_CHANNEL  2
#define WRK_CMD_QUIT           3
#define WRK_CMD_TERMINATE      4
#define WRK_CMD_REOPEN         5

#define WRK_random               random

/* TODO: #ifndef */
#define WRK_SHUTDOWN_SIGNAL      QUIT
#define WRK_TERMINATE_SIGNAL     TERM
#define WRK_NOACCEPT_SIGNAL      WINCH
#define WRK_RECONFIGURE_SIGNAL   HUP

#if (WRK_LINUXTHREADS)
#define WRK_RELEASE_SIGNAL       	 INFO
#define WRK_CHANGEBIN_SIGNAL    	 XCPU
#else
#define WRK_RELEASE_SIGNAL     		 USR1
#define WRK_RELOAD_SIGNAL       	 USR2
#endif

#ifndef WRK_HAVE_MSGHDR_MSG_CONTROL
#define WRK_HAVE_MSGHDR_MSG_CONTROL  1
#endif

#define wrk_cdecl
#define wrk_libc_cdecl


/*
 * gcc3, msvc, and icc7 compile memcpy() to the inline "rep movs".
 * gcc3 compiles memcpy(d, s, 4) to the inline "mov"es.
 * icc8 compile memcpy(d, s, 4) to the inline "mov"es or XMM moves.
 */
#define wrk_memcpy(dst, src, n)   (void) memcpy(dst, src, n)
#define wrk_cpymem(dst, src, n)   (((u_char *) memcpy(dst, src, n)) + (n))

#endif
